package com.pine.dcts.entity;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.pine.dcts.utils.Base64;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;

import java.beans.Transient;

@TableName("dcts_job_step_item")
@Setter
@Getter
public class StepItem extends BaseEntity {

    /**
     * 插件配置 进行加密处理
     */
    private String config;
    // @TableId(type = IdType.AUTO)
    private String id;
    /**
     * 插件姓名
     */
    private String name;
    /**
     * 类型
     */
    private String type;

    /**
     * x坐标点
     */
    private String x;
    /**
     * y轴坐标
     */
    private String y;
    /**
     * jobid
     */
    private Integer jobId;

    @TableField(exist = false)
    private JSONObject attrs;

    private String ico;

    public JSONObject getAttrs() {
        if (StringUtils.isNotEmpty(config)) {
            return JSON.parseObject(new String(Base64.decode(config)));
        }
        return attrs;
    }

    @Transient
    public String getConfig() {
        return config;
    }
}
